{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "view-in-github"
      },
      "source": [
        "<a href=\"https://colab.research.google.com/github/Kirie233/Chenyme-AAVT/blob/main/AAVT.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "KZa80Au0MSr7"
      },
      "source": [
        "## 简介\n",
        "\n",
        "AI Auto Video(Audio) Translation（AAVT）\n",
        "\n",
        "全自动视频翻译 项目！该项目旨在提供一个简单易用的自动识别、翻译工具和其他视频辅助工具，帮助快速识别视频字幕、翻译字幕、辅助图文。\n",
        "\n",
        "开源项目地址：[GitHub](https://github.com/Chenyme/Chenyme-AAVT)\n",
        "\n",
        "项目文档：[AAVT项目文档](https://zwho5v3j233.feishu.cn/wiki/OGcrwinzhi88MkkvEMVcLkDgnzc?from=from_copylink)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "wV1v0uISPRIZ"
      },
      "source": [
        "##克隆项目源码"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "WNX18EgVVNw7"
      },
      "outputs": [],
      "source": [
        "!git clone https://github.com/Chenyme/Chenyme-AAVT.git"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "cb7IH4HWPZ6-"
      },
      "source": [
        "# 进入项目目录"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "8tCGNuxXVwOP"
      },
      "outputs": [],
      "source": [
        "cd /content/Chenyme-AAVT"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "uhuDsKvCQhAv"
      },
      "source": [
        "## （推荐）安装cuda11.8"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "lZtIZDoseNU3"
      },
      "outputs": [],
      "source": [
        "!nvcc --version"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "kR6bZn94nVa1"
      },
      "outputs": [],
      "source": [
        "!lsb_release -a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "HmN11MMmdUUk"
      },
      "outputs": [],
      "source": [
        "#卸载当前cuda\n",
        "!apt-get --purge remove cuda nvidia* libnvidia-*\n",
        "!dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 dpkg --purge\n",
        "!apt-get remove cuda-*\n",
        "!apt autoremove\n",
        "!apt-get update"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "sMXjXJqlBPsl"
      },
      "outputs": [],
      "source": [
        "#安装cuda11.8\n",
        "!wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin\n",
        "!sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600\n",
        "!wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-ubuntu2204-11-8-local_11.8.0-520.61.05-1_amd64.deb\n",
        "!sudo dpkg -i cuda-repo-ubuntu2204-11-8-local_11.8.0-520.61.05-1_amd64.deb\n",
        "!sudo cp /var/cuda-repo-ubuntu2204-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/\n",
        "!sudo apt-get update\n",
        "!sudo apt-get -y install **cuda-11-8**"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vfB5Rz60PdyF"
      },
      "source": [
        "## 安装项目依赖"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "FPu024LqViIt"
      },
      "outputs": [],
      "source": [
        "!pip install -r requirements.txt"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XRNg2wcMPpzF"
      },
      "source": [
        "## 安装Python"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dtWOofstPrl0"
      },
      "source": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "LYiXk45zoRLC"
      },
      "outputs": [],
      "source": [
        "!apt install python3.10-venv"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qms_M03JQ2YP"
      },
      "source": [
        "##（可选项）下载faster-whisper-large-v3模型"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "1zkwN-OFXq-Z"
      },
      "outputs": [],
      "source": [
        "#mkdir /content/Chenyme-AAVT/model/whisper-large-v3\n",
        "#需要手动下载模型的话去掉#注释后执行"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "UPqAWFdIX0rj"
      },
      "outputs": [],
      "source": [
        "#cd  /content/Chenyme-AAVT/model/whisper-large-v3"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "aAbC8oHgX3pn"
      },
      "outputs": [],
      "source": [
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/README.md\n",
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/config.json\n",
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/model.bin\n",
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/preprocessor_config.json\n",
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/tokenizer.json\n",
        "#!wget https://hf-mirror.com/Systran/faster-whisper-large-v3/resolve/main/vocabulary.json\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "q25oIY6GRZyY"
      },
      "source": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "2fd_4FG1Rkr9"
      },
      "source": [
        "## 如果通过手动方式下载模式后执行下面代码回到项目目录"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "9WVh6z2gaKG_"
      },
      "outputs": [],
      "source": [
        "cd /content/Chenyme-AAVT"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "C-MYsbWpRwjN"
      },
      "source": [
        "## 激活虚拟环境"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "idEjuXY2hqgM"
      },
      "outputs": [],
      "source": [
        "!python -m venv env\n",
        "!source ./env/bin/activate"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "L0tIsTAM6n4C"
      },
      "outputs": [],
      "source": [
        "!wget -q -O - ipv4.icanhazip.com\n",
        "#获取ip"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "8CBSR45xR6eJ"
      },
      "source": [
        "## 启动webui（点击your url is后的链接，将上一步得到的ip填入）"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "Z97m_PSPt5zr"
      },
      "outputs": [],
      "source": [
        "!streamlit run Chenyme-AAVT.py & npx localtunnel --port 8501"
      ]
    }
  ],
  "metadata": {
    "accelerator": "GPU",
    "colab": {
      "authorship_tag": "ABX9TyM/NZpPomrugVSA1XayWJ6C",
      "gpuType": "T4",
      "include_colab_link": true,
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
